package com.itheima.service.impl;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.itheima.dao.ItemDao;
import com.itheima.model.Item;
import com.itheima.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author：shenkunlin
 * @date： 2021/7/5 11:49
 * @Description：
 ***/
@Service
public class ItemServiceImpl implements ItemService {

    @Autowired
    private ItemDao itemDao;

    /***
     * 削减库存，并返回单价
     * @param id
     * @param count
     * @return
     */
    @Override
    public int decrCount(Integer id, Integer count) {
        //库存削减
        int dcount = itemDao.decrCount(id,count);
        //查询单价
        return itemDao.getPrice(id);
    }

    /**
     * 根据ID查询商品详情
     * @param id
     * @return
     */
    //@SentinelResource(value = "daoone")
    @Override
    public Item one(Integer id) {
        return itemDao.one(id);
    }

}
